<?php
/**
 * Created by PhpStorm.
 * User: linux
 * Date: 15/01/2018
 * Time: 1:05 PM
 */

namespace IoC;


use IoC\SuperMan\SuperMan;
use IoC\Weapon\Gatling;
use IoC\Weapon\Gun;

function test()
{
    $container = new Container();
    $container->bind('superman', function ($container, $weaponType) {
        return new SuperMan($container->make($weaponType));
    });

    $container->bind('GatlingWeapon', function () {
        return new Gatling();
    });

    $container->bind('GunWeapon', function () {
        return new Gun();
    });


    $superMan = $container->make('superman', ['GatlingWeapon']);
    $superMan->fire();


}
